define(function(){
      var csjs=function(){
        $.getJSON('../data/shan.json',function(responseText,responseState,responseObj){
              console.log(responseText[0].data);
              analysis(responseText[0].data);
        })
      }

      function analysis(data){
              var datas=data.categories;
              var wares=data.products;
              var $myUl=$('#sscs_content>.left_nav');
              var liStr='';
              var $myDiv=$('#sscs_content');
              for(var objArr of datas){
                  var name=objArr.name;
                  var id=objArr.id;
                  var $myBox=$('<div class="right_con"></div>');
                  $myDiv.append($myBox);
                  liStr+=`<li>`+name+`</li>`;
                  var str=''
                  var newArr = wares[id];
                  for(var arrObj of newArr){
                        var img=arrObj.img;
                        var name=arrObj.name;
                        var price=arrObj.price;
                        var market_price=arrObj.market_price;
                        var specifics=arrObj.specifics;
                        var org_source_value=arrObj.org_source_value;
                        var pm_desc=arrObj.pm_desc;
                        if(price>=market_price){
                                  if(org_source_value==1){
                                              if(pm_desc){
                                                  str+=`<div class="rightWare">
                                                        <img src=`+img+`>
                                                        <div class="wareBox1">
                                                            <span class="add">＋</span>
                                                            <div class="wareBoxTop">
                                                              <h3>`+name+`</h3>
                                                              <span class="jingxuan">精选</span>
                                                              <span class="present">`+pm_desc+`<span>
                                                            </div>
                                                            <div class="wareBoxB1">
                                                                <h3>`+specifics+`</h3>
                                                                <p>￥`+price+`</p>
                                                            </div>
                                                        </div>
                                                    </div>`
                                                  }else {
                                                    str+=`<div class="rightWare">
                                                          <img src=`+img+`>
                                                          <div class="wareBox1">
                                                              <span class="add">＋</span>
                                                              <div class="wareBoxTop">
                                                                <h3>`+name+`</h3>
                                                                <span class="jingxuan">精选</span>
                                                              </div>
                                                              <div class="wareBoxB1">
                                                                  <h3>`+specifics+`</h3>
                                                                  <p>￥`+price+`</p>
                                                              </div>
                                                          </div>
                                                      </div>`
                                                  }
                                            }else if (org_source_value==2) {
                                                  if(pm_desc){
                                                      str+=`<div class="rightWare">
                                                            <img src=`+img+`>
                                                            <div class="wareBox1">
                                                                <span class="add">＋</span>
                                                                <div class="wareBoxTop">
                                                                  <h3>`+name+`</h3>
                                                                  <span class="jingxuan" style='border:none'></span>
                                                                  <span class="present">`+pm_desc+`<span>
                                                                </div>
                                                                <div class="wareBoxB1">
                                                                    <h3>`+specifics+`</h3>
                                                                    <p>￥`+price+`</p>
                                                                </div>
                                                            </div>
                                                        </div>`
                                                      }else {

                                                        str+=`<div class="rightWare">
                                                              <img src=`+img+`>
                                                              <div class="wareBox1">
                                                                  <span class="add">＋</span>
                                                                  <div class="wareBoxTop">
                                                                    <h3>`+name+`</h3>
                                                                    <span class="jingxuan" style='border:none'></span>
                                                                  </div>
                                                                  <div class="wareBoxB1">
                                                                      <h3>`+specifics+`</h3>
                                                                      <p>￥`+price+`</p>
                                                                  </div>
                                                              </div>
                                                          </div>`
                                                      }
                                            }
                                    }else {
                                        if(org_source_value==1){
                                                if(pm_desc){
                                                    str+=`<div class="rightWare">
                                                          <img src=`+img+`>
                                                          <div class="wareBox1">
                                                              <span class="add">＋</span>
                                                              <div class="wareBoxTop">
                                                                <h3>`+name+`</h3>
                                                                <span class="jingxuan">精选</span>
                                                                <span class="present">`+pm_desc+`<span>
                                                              </div>
                                                              <div class="wareBoxB1">
                                                                  <h3>`+specifics+`</h3>
                                                                  <p>￥`+price+`<span>￥`+market_price+`</span></p>
                                                              </div>
                                                          </div>
                                                      </div>`
                                                    }else {
                                                      str+=`<div class="rightWare">
                                                            <img src=`+img+`>
                                                            <div class="wareBox1">
                                                                <span class="add">＋</span>
                                                                <div class="wareBoxTop">
                                                                  <h3>`+name+`</h3>
                                                                  <span class="jingxuan">精选</span>
                                                                </div>
                                                                <div class="wareBoxB1">
                                                                    <h3>`+specifics+`</h3>
                                                                    <p>￥`+price+`<span>￥`+market_price+`</span></p>
                                                                </div>
                                                            </div>
                                                        </div>`
                                                    }
                                            }else if (org_source_value==2) {
                                                  if(pm_desc){
                                                    str+=`<div class="rightWare">
                                                          <img src=`+img+`>
                                                          <div class="wareBox1">
                                                              <span class="add">＋</span>
                                                              <div class="wareBoxTop">
                                                                <h3>`+name+`</h3>
                                                                <span class="jingxuan" style='border:none'></span>
                                                                <span class="present">`+pm_desc+`<span>
                                                              </div>
                                                              <div class="wareBoxB1">
                                                                  <h3>`+specifics+`</h3>
                                                                  <p>￥`+price+`<span>￥`+market_price+`</span></p>
                                                              </div>
                                                          </div>
                                                      </div>`
                                                    }else {
                                                      str+=`<div class="rightWare">
                                                            <img src=`+img+`>
                                                            <div class="wareBox1">
                                                                <span class="add">＋</span>
                                                                <div class="wareBoxTop">
                                                                  <h3>`+name+`</h3>
                                                                  <span class="jingxuan" style='border:none'></span>
                                                                </div>
                                                                <div class="wareBoxB1">
                                                                    <h3>`+specifics+`</h3>
                                                                    <p>￥`+price+`<span>￥`+market_price+`</span></p>
                                                                </div>
                                                            </div>
                                                        </div>`
                                                    }
                                            }
                                    }
                  }
                  $myBox.html(str);
              }



              $myUl.html(liStr);

              var $lis=$('#sscs_content>.left_nav li');
              var $divs=$('#sscs_content>.right_con');
              $divs[0].style.display='block';
              for(var i=0; i<$lis.length; i++){
                  $lis[i].temp=i;
                  $($lis[i]).click(function(){
                      for(var j=0; j<$divs.length; j++){
                        $divs[j].style.display='none';
                      }
                      $divs[this.temp].style.display='block';
                  })

              }





      }





      return{
         csjs:csjs
      }
})
